/**
 * 	feed 操作类
 */

var CommentAction = {
		
		/*
		 * 展开评论
		 */
		showCommentListOfFeed:function(event_id)
		{		
			$.ajax({
				  url: "/index.php?r=feed/comments",
				  data: {'event_id':event_id},
				  success: function(data){
					  $('#feedbody'+event_id).html(data._html);
					  $('#feedbody'+event_id).show();
				  },
				  dataType: "json"
				});
		},

		/*
		 * @展开评论框 
		 */
		showCommentTXTOfFeed:function(obj)
		{
			var _textareaId = obj.id;
			var _textareaIdtmp = _textareaId.split('-');
			$('#feed-comment-'+_textareaIdtmp[1]).addClass('feed-comment feed-comment-expand');
		},

		hideCommentTXTOfFeed:function(obj)
		{
			//空值的时候折回去
			if(obj.value == '')
			{
				var _textareaId = obj.id;
				var _textareaIdtmp = _textareaId.split('-');
				$('#feed-comment-'+_textareaIdtmp[1]).attr("class","feed-comment");
			}
		},

		/*
		 *	@发表评论 
		 */
		createCommentOfFeed:function(event_id)
		{
			_contentVal = $('#contenttextarea-'+event_id).val();
			$.ajax({
				  url: "/index.php?r=feed/addcomment",
				  data: {'event_id':event_id,'contentval':_contentVal},
				  success: function(data){
						$('#contenttextarea-'+event_id).val('');
						$('#feed-comment-'+event_id).attr("class","feed-comment");
						
						//重新load，这个地方写不好，以后改成直接返回HTML
						CommentAction.showCommentListOfFeed(event_id);
				  },
				  dataType: "json"
				});
		}
};
